<?php

namespace App\Console\Commands;

use App\Models\User;
use Illuminate\Console\Command;

/**
 * 生成活跃的用户
 *
 * Class CalculateActiveUser
 * @package App\Console\Commands
 */
class CalculateActiveUser extends Command
{
    /**
     * 供我们调用的命令
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'larabbs:calculate-active-user';

    /**
     * 命令描述
     * The console command description.
     *
     * @var string
     */
    protected $description = '生成活跃的用户';

    /**
     * 最终执行的方法
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle(User $user)
    {
        // 在命令行打印一行信息
        $this->info("开始计算...");

        $user->calculateAndCacheActiveUsers();

        $this->info("生成完成");
    }
}
